import storage from '@/utils/storage'

const user = {
  state: {
    name: storage.get('userName') || '游客',
    avatar: ''
  },

  mutations: {
    SET_NAME: (state, name) => {
      state.name = name
      storage.set('userName', name)
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
      storage.set('userAvatar', avatar)
    }
  },

  actions: {
    // 可以在这里添加游戏相关的用户操作
  }
}

export default user
